package cn.study.luckyadapter.controller;

import cn.study.common.annotation.ResponseResult;
import cn.study.luckyapp.activity.command.RedisDeductionNumberExe;
import cn.study.luckyapp.listener.AwardInventoryToRedisApplicationListener;
import cn.study.luckyapp.mq.product.ActivityDrawMessageProducer;
import lombok.AllArgsConstructor;
import org.bouncycastle.util.encoders.UTF8;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@ResponseResult
@RequestMapping("/v1/test")
@AllArgsConstructor
public class TestController {
    private final RedisDeductionNumberExe redisDeductionNumberExe;
    private final ActivityDrawMessageProducer activityDrawMessageProducer;
    @PostMapping("/deduction")
    public Integer test(){
        return redisDeductionNumberExe.InvokeDeductionInventory(AwardInventoryToRedisApplicationListener.getKey(25L,31L));
    }
    @GetMapping("/send")
    public void send(){
        activityDrawMessageProducer.sendMessage();
    }
    @GetMapping("/test")
    public void test1(HttpServletRequest request){
        String id = request.getHeader("id");
        System.out.println(id);
    }
}
